home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
graphic
/
cheetah.zip
/
UGETZ4P.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-21
|
4KB
|
135 lines
/* -- Not realized -- */
/* ugetz4p.c
*
* UNCHAINED mode version.
* NOTE that in this mode BPERROW is a permanent constant, and always equal to
* BPERROW_CHAINED.
*
* Description:
* Get screen image and encode it to Z4Planes format.
*
* Function list:
* UgetZ4Planes().
*
* Portability: BORLANDC
* (c) erdy 1992
* $Header: $
*/
#pragma inline
#include <limits.h>
#include <alloc.h> /* farcoreleft() */
#include "far.h"
#include "vgaprefx.h"
#include "vgadrv.h"
#include "screen.h"
#include "mxcpy.h"
Image far *UgetZ4Planes(unsigned int x, unsigned int y,
unsigned int nc, unsigned int nr,
int backcolor)
{
return(0);
#if 0
char far *p;
Image far *ip;
auto unsigned int sz;
auto unsigned long coreleft;
auto unsigned int ncols;
auto unsigned int n;
auto unsigned int pl;
auto unsigned int row, col;
auto unsigned char lastoff;
auto union bw {
char b[2];
int w;
} bc;
bc.w = backcolor;
coreleft = (unsigned long)nc * nr;
coreleft += sizeof(Image);
if (coreleft > UINT_MAX)
sz = UINT_MAX;
else
sz = coreleft;
if ((coreleft = farcoreleft()/2) > UINT_MAX)
coreleft = UINT_MAX;
if (sz > coreleft)
coreleft = sz;
coreleft -= 6;
If_Overflow:
if ((p = getmem(sz)) == NULL) {
Abort:
scerror = ER_OUTOFMEM;
return(NULL);
}
sz -= 6;
y = VIDEO_ADDRESS(x, y); /* Will keep video RAM offset */
x &= 3; /* Will keep starting offset */
/* nc will keep number of completed 4s, plus 1st one (maybe incompleted) */
n = (lastoff = x + nc)/BITPLANES;
lastoff &= 3; /* Offset of last pixel in group-of-4 */
_A_selectMap(); /* Point gate to Select Map register */
asm cld;
asm push ds;
asm les di, p; /* Load data address */
_AX = Scdraw_seg; /* Load video address */
_DS = _AX;
asm xor dx, dx; /* Clear the used space counter */
for (pl = 1; pl <= BITPLANES; pl++) {
asm push dx; /* Save space counter */
ncols = n;
_AL = pl + x; /* To reach proper plane's order */
if (_AL > BITPLANES) { /* Wrap across 4-group */
_AL -= BITPLANES;
y++; /* Increment VRAM offset */
ncols--; /* Not present in the 1st group-of-4 */
}
if (_AL <= lastoff)
ncols++; /* Present in the last group-of-4 */
_D_selectMap(_AL); /* Select correct plane of {1,2,3,4} */
asm pop dx; /* Restore counter */
_SI = y; /* Set starting video offset */
for (row = 0; row < nr; row++) {
asm pop si;
asm add si, BPERROW_UNCHAINED; /* Advance to next row */
}
}
sz = _DX;
asm pop ds;
if ((ip = (Image far *)getmem((unsigned long)sz + sizeof(Image))) == NULL) {
retmem(p);
scerror = ER_OUTOFMEM;
return(NULL);
}
/* Copy data */
_offset(ip) = sizeof(Image); /* _offset(ip) was equal to 0 ! */
_mxcpy(p, ip, sz);
retmem(p);
/* Establish image */
_offset(ip) = 0;
ip->d.size = sz;
ip->d.twidth = ip->d.width = nc;
ip->d.theight = ip->d.height = nr;
ip->d.ncolormaps = ip->d.x = ip->d.y = 0;
ip->d.format = Z4Planes;
p = (char far *)ip + sizeof(Image);
_farnormal(p); /* Offset p must be 0 ! */
ip->d.data = p;
return(ip);
#endif
}